import { createRouter, /*createWebHistory,*/ createWebHashHistory } from 'vue-router'

const router = createRouter({
  // history: createWebHistory(import.meta.env.BASE_URL),
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/home.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/login.vue')
    },

    // 404
    {
      path: '/:pathMatch(.*)*',
      redirect: '/',
      name: 'not-found'
      // component: () => import('@/views/404.vue'),
    }
  ],
  scrollBehavior: () => {
    return {
      behavior: 'auto', // "auto" | "instant" | "smooth"
      left: 0,
      top: 0
    }
  }
})

router.beforeEach((to, from, next) => {
  // if (to.path === '/login' && !import.meta.env.DEV) {
  //   next(false)
  //   return false
  // }
  next()
})

export default router
